﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace VeryCodes.Controls.Web
{
    /// <summary>
    ///TopDescription 的摘要说明
    /// </summary>
    [ParseChildren(true)]
    public class TopDescription : CompositeControl
    {
        public TopDescription()
        {
        }

        //声明变量
        private ITemplate _title;
        private ITemplate _description;
        private Panel _titleArea;
        private Panel _descriptionArea;

        //属性
        [Browsable(false)]
        [TemplateContainer(typeof(TopDescription))]
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public ITemplate Title
        {
            get
            {
                return _title;
            }
            set
            {
                _title = value;
            }
        }

        [Browsable(false)]
        [TemplateContainer(typeof(TopDescription))]
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public ITemplate Description
        {
            get
            {
                return _description;
            }
            set
            {
                _description = value;
            }
        }

        protected override void CreateChildControls()
        {
            Controls.Clear();
            _titleArea = new Panel();

            if (_title != null)
            {
                _title.InstantiateIn(_titleArea);
            }
            Controls.Add(_titleArea);

            _descriptionArea = new Panel();
            if (_description != null)
            {
                _description.InstantiateIn(_descriptionArea);
            }
            Controls.Add(_descriptionArea);
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            writer.WriteLine("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"contenttable\">");
            writer.WriteLine("<tr>");
            writer.WriteLine("<td>");
            writer.WriteLine("<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">");
            writer.WriteLine("<tr>");
            writer.WriteLine("<td width=\"31\" height=\"36\" rowspan=\"2\"><img border=\"0\" src=\"images/rectangle/jiao_r.png\"></td>");
            writer.WriteLine("<td background=\"images/rectangle/line_t.gif\"></td>");
            writer.WriteLine("<td rowspan=\"2\" background=\"images/rectangle/more_b1.png\" height=\"36\" width=\"95\" class=\"righttext\"></td>");
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr>");
            writer.WriteLine("<td class=\"rectangletitle\">");
            _titleArea.RenderControl(writer);
            writer.WriteLine("</td>");
            writer.WriteLine("</tr>");
            writer.WriteLine("</table>");
            writer.WriteLine("</td>");
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr>");
            writer.WriteLine("<td>");
            writer.WriteLine("<table border=\"0\" width=\"100%\" id=\"table3\" cellspacing=\"0\" cellpadding=\"0\">");
            writer.WriteLine("<tr>");
            writer.WriteLine("<td background=\"images/rectangle/line_l.gif\" width=\"8\" rowspan=\"2\">");
            writer.WriteLine("</td>");
            writer.WriteLine("<td background=\"images/rectangle/line_g.gif\" height=\"3\">");
            writer.WriteLine("</td>");
            writer.WriteLine("<td background=\"images/rectangle/line_r.gif\" width=\"11\" rowspan=\"2\">");
            writer.WriteLine("</td>");
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr>");
            writer.WriteLine("<td valign=\"top\" style=\"line-height: 20px;\">");
            _descriptionArea.RenderControl(writer);
            writer.WriteLine("</td>");
            writer.WriteLine("</tr>");
            writer.WriteLine("</table>");
            writer.WriteLine("</td>");
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr>");
            writer.WriteLine("<td>");
            writer.WriteLine("<table border=\"0\" width=\"100%\" id=\"table5\" cellspacing=\"0\" cellpadding=\"0\">");
            writer.WriteLine("<tr>");
            writer.WriteLine("<td height=\"12\" width=\"8\">");
            writer.WriteLine("<img border=\"0\" src=\"images/rectangle/jiao_003.gif\" width=\"8\" height=\"12\">");
            writer.WriteLine("</td>");
            writer.WriteLine("<td background=\"images/rectangle/line_d.gif\" width=\"100%\">");
            writer.WriteLine("</td>");
            writer.WriteLine("<td width=\"11\">");
            writer.WriteLine(" <img border=\"0\" src=\"images/rectangle/jiao_004.gif\" width=\"11\" height=\"12\">");
            writer.WriteLine("</td>");
            writer.WriteLine("</tr>");
            writer.WriteLine("</table>");
            writer.WriteLine("</td>");
            writer.WriteLine("</tr>");
            writer.WriteLine("</table>");

            //base.RenderContents(writer);
        }
    }
}